package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.model.UmsMember;
import com.fc.mall.portal.domain.SignQueryParam;
import com.fc.mall.portal.dto.MemberSignDto;
import com.fc.mall.portal.dto.UmsMemberSignDto;
import com.fc.mall.portal.service.UmsMemberService;
import com.fc.mall.portal.service.UmsMemberSignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Validated
@RestController
@Api(tags = "UmsMemberSignController", description = "会员签到")
@RequestMapping("/member/signs")
public class UmsMemberSignController {
    @Autowired
    private UmsMemberService memberService;

    @Autowired
    private UmsMemberSignService memberSignService;

    @Autowired
    private MapperFacade mapperFacade;

    @ApiOperation("签到")
    @PostMapping
    public Result sign() {
        UmsMember authMember = memberService.getCurrentMember();
        MemberSignDto memberSignDto = memberSignService.sign(authMember.getId());
        return Result.success(memberSignDto);
    }

    @ApiOperation("获得签到数据")
    @GetMapping
    public Result getSign(SignQueryParam signQueryParam) {

        List<UmsMemberSignDto> memberSignDto = memberSignService.getMemberSign(signQueryParam);

        return Result.success(memberSignDto);
    }


}
